using System;
using System.Collections.Generic;
using System.Diagnostics;
using Volo.Abp.Application.Services;

namespace MatrixFramework.Shared.Contracts.Monitoring
{
    /// <summary>
    /// OpenTelemetry分布式追踪服务接口
    /// 符合ABP vNext规范，定义在Contracts层
    /// </summary>
    public interface IOpenTelemetryService : IApplicationService
    {
        /// <summary>
        /// 创建追踪活动
        /// </summary>
        /// <param name="operationName">操作名称</param>
        /// <param name="tags">标签</param>
        /// <returns>活动</returns>
        IDisposable StartOperation(string operationName, Dictionary<string, object>? tags = null);

        /// <summary>
        /// 记录指标
        /// </summary>
        /// <param name="metricName">指标名称</param>
        /// <param name="value">值</param>
        /// <param name="tags">标签</param>
        void RecordMetric(string metricName, double value, Dictionary<string, object>? tags = null);

        /// <summary>
        /// 增加计数器
        /// </summary>
        /// <param name="counterName">计数器名称</param>
        /// <param name="tags">标签</param>
        void IncrementCounter(string counterName, Dictionary<string, object>? tags = null);

        /// <summary>
        /// 记录直方图数据
        /// </summary>
        /// <param name="histogramName">直方图名称</param>
        /// <param name="value">值</param>
        /// <param name="tags">标签</param>
        void RecordHistogram(string histogramName, double value, Dictionary<string, object>? tags = null);

        /// <summary>
        /// 设置仪表盘值
        /// </summary>
        /// <param name="gaugeName">仪表盘名称</param>
        /// <param name="value">值</param>
        /// <param name="tags">标签</param>
        void SetGauge(string gaugeName, double value, Dictionary<string, object>? tags = null);

        /// <summary>
        /// 添加事件到当前活动
        /// </summary>
        /// <param name="eventName">事件名称</param>
        /// <param name="tags">标签</param>
        void AddEvent(string eventName, Dictionary<string, object>? tags = null);

        /// <summary>
        /// 设置标签到当前活动
        /// </summary>
        /// <param name="tags">标签</param>
        void SetTags(Dictionary<string, object> tags);

        /// <summary>
        /// 记录异常到当前活动
        /// </summary>
        /// <param name="exception">异常</param>
        void RecordException(Exception exception);
    }
}